<div [@routerTransition]>
    <div class="m-subheader">
        <div class="row align-items-center">
            <div class="mr-auto col-auto">
                <h3 class="m-subheader__title m-subheader__title--separator">
                    <span>工时月度报表</span>
                </h3>
                <span class="m-section__sub">
                    月度车间工时统计报表
                </span>
            </div>
            <div class="col text-right mt-3 mt-md-0" style="float: inherit;">
                <input
                    type="text"
                    class="form-control"
                    #dp="bsDatepicker"
                    [bsConfig]="bsConfig"
                    style="width: 150px; display: inline;"
                    locale="zh-cn"
                    placeholder="开始月份"
                    bsDatepicker
                    [(bsValue)]="filterStartTime"
                    readonly
                />
                <input
                    type="text"
                    class="form-control"
                    #dp="bsDatepicker"
                    [bsConfig]="bsConfig"
                    style="margin-left: 20px;"
                    style="width: 150px; display: inline;"
                    locale="zh-cn"
                    placeholder="结束月份"
                    bsDatepicker
                    [(bsValue)]="filterEndTime"
                    readonly
                />

                <button
                    type="button"
                    class="btn btn-primary blue m--margin-left-20"
                    (click)="getReport()"
                >
                    <i class="fa fa-retweet"></i> 查询
                </button>
                <button
                    type="button"
                    class="btn btn-success"
                    [busyIf]="primengTableHelperNormalReport.isLoading"
                    (click)="exportToExcel()"
                >
                    <i class="fa fa-plus"></i> 导出
                </button>
            </div>
        </div>
    </div>

    <div class="m-content">
        <div class="m-portlet m-portlet--mobile">
            <div class="m-portlet__body">
                <div class="m-form m-form--label-align-right">
                    <form class="horizontal-form">
                        <!-- (ngSubmit)="getNormalProduction()" -->
                        <div class="row align-items-center m--margin-bottom-10">
                            <div class="col-md-3">
                                <div class="form-group">
                                    <label
                                        for="FilterPicNo"
                                        class="control-label"
                                        >任务号</label
                                    >
                                    <input
                                        id="FilterPicNo"
                                        type="text"
                                        name="FilterPicNo"
                                        class="form-control"
                                        [(ngModel)]="filterPicNo"
                                    />
                                </div>
                            </div>
                            <div class="col-md-3">
                                <div class="form-group">
                                    <label
                                        for="FilterTaskNo"
                                        class="control-label"
                                        >图号</label
                                    >
                                    <input
                                        id="FilterTaskNo"
                                        type="text"
                                        name="FilterTaskNo"
                                        class="form-control"
                                        [(ngModel)]="filterTaskNo"
                                    />
                                </div>
                            </div>
                            <div class="col-md-3">
                                <div class="form-group">
                                    <label
                                        for="FilterTaskNo"
                                        class="control-label"
                                        >车间</label
                                    >
                                    <select
                                        #workshoFilterCombobox
                                        name="workshoFilter"
                                        class="form-control"
                                        [(ngModel)]="filterDpt"
                                        required
                                    >
                                        <option value="">所有车间</option>
                                        <option
                                            *ngFor="
                                                let workShop of workShopList
                                            "
                                            [value]="workShop.value"
                                        >
                                            {{ workShop.displayText }}</option
                                        >
                                    </select>
                                </div>
                            </div>
                            <div class="col-md-3">
                                <div class="form-group">
                                    <label
                                        for="FilterName"
                                        class="control-label"
                                        >名称</label
                                    >
                                    <input
                                        id="FilterName"
                                        name="FilterName"
                                        type="text"
                                        class="form-control"
                                        [(ngModel)]="filterName"
                                    />
                                </div>
                            </div>
                        </div>

                        <div *ngIf="advancedFiltersAreShown" class="row">
                            <div class="col-md-3">
                                <div class="form-group">
                                    <label
                                        for="FilterModel"
                                        class="control-label"
                                        >型号</label
                                    >
                                    <input
                                        id="FilterModel"
                                        name="FilterModel"
                                        type="text"
                                        class="form-control"
                                        [(ngModel)]="filterModel"
                                    />
                                </div>
                            </div>
                            <div class="col-md-3">
                                <div class="form-group">
                                    <label
                                        for="FilterPart"
                                        class="control-label"
                                        >部段</label
                                    >
                                    <input
                                        id="FilterPart"
                                        type="text"
                                        name="FilterPart"
                                        class="form-control"
                                        [(ngModel)]="filterPart"
                                    />
                                </div>
                            </div>
                            <div class="col-md-3">
                                <div class="form-group">
                                    <label
                                        for="TeamGroupName"
                                        class="control-label"
                                        >班组</label
                                    >
                                    <input
                                        id="TeamGroupName"
                                        type="text"
                                        name="TeamGroupName"
                                        class="form-control"
                                        [(ngModel)]="filterTeamGroupName"
                                    />
                                </div>
                            </div>
                        </div>
                        <div class="row m--margin-bottom-10">
                            <div class="col-sm-6">
                                <span
                                    class="clickable-item text-muted"
                                    *ngIf="!advancedFiltersAreShown"
                                    (click)="
                                        advancedFiltersAreShown = !advancedFiltersAreShown
                                    "
                                    ><i class="fa fa-angle-down"></i>
                                    显示更多</span
                                >
                                <span
                                    class="clickable-item text-muted"
                                    *ngIf="advancedFiltersAreShown"
                                    (click)="
                                        advancedFiltersAreShown = !advancedFiltersAreShown
                                    "
                                    ><i class="fa fa-angle-up"></i> 收起</span
                                >
                            </div>
                        </div>
                    </form>
                </div>

                <!-- <div class="row margin-bottom-10">
                    <div class="col-sm-12 text-right">
                        <button
                            type="button"
                            class="btn btn-success"
                            [busyIf]="primengTableHelperNormalReport.isLoading"
                            (click)="exportToExcel()"
                        >
                            <i class="fa fa-plus"></i> 导出
                        </button>
                    </div>
                </div> -->
                <div class="row align-items-center">
                    <!--<Primeng-TurboTable-Start>-->
                    <div
                        class="primeng-datatable-container"
                        [busyIf]="primengTableHelperNormalReport.isLoading"
                    >
                        <p-table
                            #dataTableNormalProductions
                            [value]="primengTableHelperNormalReport.records"
                            (onLazyLoad)="getReport($event)"
                            rows="{{
                                primengTableHelperNormalReport.defaultRecordsCountPerPage
                            }}"
                            [paginator]="false"
                            [lazy]="true"
                            scrollable="true"
                            ScrollWidth="100%"
                            responsive="primengTableHelperNormalReport.isResponsive"
                            resizableColumns="primengTableHelperNormalReport.resizableColumns"
                        >
                            <ng-template pTemplate="header">
                                <tr>
                                    <th pSortableColumn="monthOfLaborHour">
                                        月份
                                        <p-sortIcon
                                            field="monthOfLaborHour"
                                        ></p-sortIcon>
                                    </th>
                                    <th pSortableColumn="dpt">
                                        车间
                                        <p-sortIcon field="dpt"></p-sortIcon>
                                    </th>
                                    <th pSortableColumn="teamGroupName">
                                        班组
                                        <p-sortIcon
                                            field="teamGroupName"
                                        ></p-sortIcon>
                                    </th>
                                    <th pSortableColumn="model">
                                        型号
                                        <p-sortIcon field="model"></p-sortIcon>
                                    </th>
                                    <th pSortableColumn="mainTaskCode">
                                        任务号
                                        <p-sortIcon
                                            field="mainTaskCode"
                                        ></p-sortIcon>
                                    </th>
                                    <th pSortableColumn="picNo">
                                        图号
                                        <p-sortIcon field="picNo"></p-sortIcon>
                                    </th>
                                    <th pSortableColumn="name">
                                        名称
                                        <p-sortIcon field="name"></p-sortIcon>
                                    </th>

                                    <th pSortableColumn="part">
                                        部段
                                        <p-sortIcon field="part"></p-sortIcon>
                                    </th>
                                    <th>
                                        数量
                                    </th>
                                    <th pSortableColumn="laborHour">
                                        工时
                                        <p-sortIcon
                                            field="laborHour"
                                        ></p-sortIcon>
                                    </th>
                                    <th pSortableColumn="remark">
                                        备注
                                    </th>
                                </tr>
                            </ng-template>
                            <ng-template
                                pTemplate="body"
                                let-record="$implicit"
                            >
                                <tr>
                                    <td>
                                        <span class="ui-column-title"
                                            >月份</span
                                        >
                                        {{
                                            record.monthOfLaborHour
                                                | momentFormat: "YYYY-MM"
                                        }}
                                    </td>
                                    <td>
                                        <span class="ui-column-title"
                                            >车间</span
                                        >
                                        {{ record.dpt }}
                                    </td>
                                    <td>
                                        <span class="ui-column-title"
                                            >班组</span
                                        >
                                        {{ record.teamGroupName }}
                                    </td>
                                    <td>
                                        <span class="ui-column-title"
                                            >型号</span
                                        >
                                        {{ record.model }}
                                    </td>
                                    <td>
                                        <span class="ui-column-title"
                                            >任务号</span
                                        >
                                        {{ record.mainTaskCode }}
                                    </td>

                                    <td>
                                        <span class="ui-column-title"
                                            >图号</span
                                        >
                                        {{ record.picNo }}
                                    </td>
                                    <td>
                                        <span class="ui-column-title"
                                            >名称</span
                                        >
                                        {{ record.name }}
                                    </td>

                                    <td>
                                        <span class="ui-column-title"
                                            >部段</span
                                        >
                                        {{ record.part }}
                                    </td>
                                    <td>
                                        <span class="ui-column-title"
                                            >数量</span
                                        >
                                        {{ record.quantity }}
                                    </td>
                                    <td>
                                        <span class="ui-column-title"
                                            >工时</span
                                        >
                                        {{ record.laborHour }}
                                    </td>

                                    <td title=" {{ record.remark }}">
                                        <span class="ui-column-title"
                                            >备注</span
                                        >
                                        {{ record.remark.substr(0, 10) }}
                                    </td>
                                </tr>
                            </ng-template>
                        </p-table>
                        <div
                            class="primeng-no-data"
                            *ngIf="
                                primengTableHelperNormalReport.totalRecordsCount ==
                                0
                            "
                        >
                            没有数据
                        </div>
                        <div class="primeng-paging-container">
                            <p-paginator
                                [rows]="
                                    primengTableHelperNormalReport.defaultRecordsCountPerPage
                                "
                                #paginatorNormal
                                (onPageChange)="getReport($event)"
                                [totalRecords]="
                                    primengTableHelperNormalReport.totalRecordsCount
                                "
                                [rowsPerPageOptions]="
                                    primengTableHelperNormalReport.predefinedRecordsCountPerPage
                                "
                            >
                            </p-paginator>
                            <span class="total-records-count">
                                共
                                {{
                                    primengTableHelperNormalReport.totalRecordsCount
                                }}
                                条
                            </span>
                        </div>
                    </div>
                    <!--<Primeng-TurboTable-End>-->
                </div>
            </div>
        </div>
    </div>
</div>
